package com.hc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hc.domain.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 查询指定id的用户所具有的角色
     * @param userId
     * @return
     */
    @Select("SELECT tb_role.id, tb_role.`code` " +
            "FROM tb_role " +
            "	INNER JOIN tb_user_role ON tb_role.id = tb_user_role.role_id " +
            "WHERE user_id = #{userId}")
    List<Role> selectRoleByUserId(@Param("userId") Integer userId);
}
